<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<html>
<head>
    <title>我的收藏</title>
    <link rel="icon" href="./favicon/favicon.ico" type="image/x-icon">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.bootcdn.net/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/bootstrap-icons/1.11.1/font/bootstrap-icons.css">
</head>
<body class="bg-light">
<div class="container py-4">
    <h4 class="mb-4"><i class="bi bi-star-fill text-warning"></i> 我的收藏</h4>

    <c:if test="${empty favoriteList}">
        <div class="alert alert-info">暂无收藏</div>
    </c:if>

    <div class="row g-3">
        <c:forEach items="${favoriteList}" var="f">
            <div class="col-12">
                <div class="card shadow-sm">
                    <div class="card-body">
                        <h5 class="card-title">
                            <a href="articleServlet?method=findByTitle&id=${f.articleId}" class="text-decoration-none">
                                <i class="bi bi-file-earmark-text"></i> ${f.title}
                            </a>
                        </h5>
                        <p class="card-text text-muted small">${fn:substring(f.content, 0, 120)}…</p>

                        <div class="d-flex justify-content-between align-items-center">
                            <small class="text-muted">
                                <i class="bi bi-person-circle"></i> 作者：${f.username}
                            </small>
                            <small class="text-muted">
                                <i class="bi bi-calendar"></i> ${f.createTime}
                            </small>
                        </div>
                    </div>
                </div>
            </div>
        </c:forEach>
    </div>

    <div class="mt-4">
        <a href="javascript:history.back()" class="btn btn-secondary btn-sm">
            <i class="bi bi-arrow-left"></i> 返回
        </a>
    </div>
</div>
</body>
</html>